package com.gamenew.bluetoothdemo.ui;

import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/10/18 0018.
 */

public abstract class BaseActivity extends AppCompatActivity {

    private ProgressDialog mDialog;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(setResourcesId());
        ButterKnife.bind(this);

        initView();
    }

    protected void initView() {
    }

    protected void initDialog() {
        mDialog = new ProgressDialog(this);
        mDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        mDialog.setCancelable(true);//back键是否可以取消
        mDialog.setCanceledOnTouchOutside(false);
    }

    protected abstract int setResourcesId();

    protected void showProgressDialog(String msg) {
        mDialog.setMessage(msg);
        mDialog.show();
    }

    protected void dismissProgressDialog() {
        mDialog.cancel();
        mDialog.dismiss();
    }

    protected void showToast(String text) {
        Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
    }

}
